window.addEventListener("load", function () {
	// 轮播图

	var mySwiper = new Swiper(".swiper", {
		autoplay: true, //可选选项，自动滑动
		pagination: {
			el: ".swiper-pagination",
			clickable: true,
		},
	});

	//如果你初始化时没有定义Swiper实例，后面也可以通过Swiper的HTML元素来获取该实例
	new Swiper(".swiper");
	var mySwiper = document.querySelector(".swiper").swiper;
	mySwiper.slideNext();

	// API服务区
	let box31 = $("#box31 div");
	box31.forEach(function (v, i) {
		v.addEventListener("mouseover", function () {
			console.log(v.firstElenmentChild);
			v.style.backgroundColor = "#2f7ee9";
			v.style.color = "#fff";
			v.firstElementChild.src = `../imgs/api0${i + 1}-c.svg`;
		});
		v.addEventListener("mouseout", function () {
			console.log(v.firstElenmentChild);
			v.style.backgroundColor = "#fff";
			v.style.color = "#000";
			v.firstElementChild.src = `../imgs/api0${i + 1}.svg`;
		});
	});

	// 独角兽区轮播图;
	// 获取轮播图的数组
	let box51 = $(".box51>div");
	// 声明一个标杆
	let bannerTime = 0;
	// 默认第一个banner图显示
	box51[0].style.opacity = 1;
	// 设置自动函数,3秒切换一次
	this.window.setInterval(function () {
		// 每三秒将轮播图背景色设置为透明
		box51.forEach(function (v) {
			v.style.opacity = 0;
		});
		box51[bannerTime].style.opacity = 1;
		// 使对应索引透明度到1
		bannerTime++;
		// 判断如果标杆大于等于了数组长度，则让标杆归零
		if (bannerTime > box51.length - 1) {
			bannerTime = 0;
		}
		console.log(bannerTime);
	}, 3000);

	// 设置点击事件，弹出警告框没有链接提示
	$(".click").forEach(function (v) {
		v.addEventListener("click", function () {
			window.confirm("暂无跳转喔！");
		});
	});
});
